﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using BCDto.Common.OA.WorkOvertimeExamineRecord;
using BCService.CommonService.OA.WorkOvertimeExamineRecord;
using BlackCoffeeRESTful.Configs;

namespace BlackCoffeeRESTful.Controllers.Management.OA
{
    /// <summary>
    /// 加班信息审批流程服务接口
    /// </summary>
    [ApiExplorerSettings(GroupName = "OAAdmin")]
    [Route("api/v1/sim/[controller]")]
    public class WorkOvertimeExamineRecordController : ManagementBaseController
    {
        private readonly IWorkOvertimeExamineRecordService workOvertimeExamineRecordService;

        public WorkOvertimeExamineRecordController(IWorkOvertimeExamineRecordService workOvertimeExamineRecordService)
        {
            this.workOvertimeExamineRecordService = workOvertimeExamineRecordService;
        }

        #region 获取某条加班信息的审批流程状态

        /// <summary>
        /// 获取某条加班信息的审批流程状态
        /// </summary>
        /// <param name="workOverTimeRecordNo">加班信息编号</param>
        /// <response code="200">加班信息的审批流程状态信息</response>
        /// <returns></returns>
        [HttpGet("{work_overtime_record_no}")]
        [ProducesResponseType(typeof(List<WorkOvertimeExamineRecordDto>), 200)]

        public IActionResult Get([FromRoute(Name = "work_overtime_record_no")] string workOverTimeRecordNo)
        {
            return Ok(this.workOvertimeExamineRecordService.GetListByWorkOvertimeRecordNo(workOverTimeRecordNo));
        }

        #endregion

        #region 审批加班信息
        /// <summary>
        /// 审批加班信息
        /// </summary>
        /// <param name="workOverTimeRecordNo">加班信息编号</param>
        /// <param name="workOvertimeExamineRecordSimPutDto">审批信息</param>
        /// <response code="200">当前操作执行结果True成功，False失败</response>
        /// <returns></returns>
        [HttpPut("[action]/{work_overtime_record_no}")]
        [Log("审批加班信息")]
        public IActionResult ExamineWorkOvertime([FromRoute(Name = "work_overtime_record_no")] string workOverTimeRecordNo ,[FromBody] WorkOvertimeExamineRecordSimPutDto workOvertimeExamineRecordSimPutDto)
        {
            this.workOvertimeExamineRecordService.Examine(workOverTimeRecordNo, this.Admin.AdminId, workOvertimeExamineRecordSimPutDto);
            return Ok();
        }
        #endregion
    }
}